package cn.rkylin.oms.system.log.domain;

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;

import org.apache.commons.lang.StringUtils;

public class SearchConditions {

	private boolean quickSearch;
	private String keyword;
	private String bizId;
	private String tag;
	private String user;
	private String operation;
	private String operStartTime;
	private String operEndTime;
	private String sourceType;
	private String logType;

	public boolean isQuickSearch() {
		return quickSearch;
	}

	public void setQuickSearch(boolean quickSearch) {
		this.quickSearch = quickSearch;
	}

	public String getKeyword() {
		return keyword;
	}

	public void setKeyword(String keyword) {
		this.keyword = keyword;
	}

	public String getBizId() {
		return bizId;
	}

	public void setBizId(String bizId) {
		this.bizId = bizId;
	}

	public String getTag() {
		return tag;
	}

	public void setTag(String tag) {
		this.tag = tag;
	}

	public String getUser() {
		return user;
	}

	public void setUser(String user) {
		this.user = user;
	}

	public String getOperation() {
		return operation;
	}

	public void setOperation(String operation) {
		this.operation = operation;
	}

	public String getOperStartTime() {
		return operStartTime;
	}

	public void setOperStartTime(String operStartTime) {
		this.operStartTime = operStartTime;
	}

	public String getOperEndTime() {
		return operEndTime;
	}

	public void setOperEndTime(String operEndTime) {
		this.operEndTime = operEndTime;
	}

	public String getSourceType() {
		return sourceType;
	}

	public void setSourceType(String sourceType) {
		this.sourceType = sourceType;
	}

	public String getLogType() {
		return logType;
	}

	public void setLogType(String logType) {
		this.logType = logType;
	}

	public void decode() {
		this.keyword = decodeParameter(this.keyword);
		this.bizId = decodeParameter(this.bizId);
		this.tag = decodeParameter(this.tag);
		this.user = decodeParameter(this.user);
		this.operation = decodeParameter(this.operation);
		this.sourceType = decodeParameter(this.sourceType);
		this.logType = decodeParameter(this.logType);
	}

	private String decodeParameter(String value) {
		if (!StringUtils.isNotBlank(value)) {
			return null;
		}

		String decoded = null;
		try {
			decoded = URLDecoder.decode(value, "UTF-8");
		} catch (UnsupportedEncodingException ignore) {
		}

		return decoded;
	}

}
